﻿using Microsoft.SharePoint.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SharePointHostedHelloWorldWeb.Pages
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // The following code gets the client context and Title property by using TokenHelper.
            // To access other properties, you may need to request permissions on the host web.

            ClientContext clientContext = TokenHelper.GetClientContextWithAccessToken(hostWebUrl, accessToken);

            //Shortcuts:
            //- OAuth: TokenHelper.GetClientContextWithContextToken(hostWebUrl, contextTokenString, Request.Url.Authority)
            //- S2S:   TokenHelper.GetS2SclientContextWithWindowsIdentity(hostWebUrl, Request.LogonUserIdentity)


            //Get the lists from the HostWeb
            ListCollection lists = web.Lists;
            clientContext.Load<ListCollection>(lists);
            clientContext.ExecuteQuery();
        }
    }
}